package BeenChina.PM.Model;

import java.util.List;
 

/**
 * @author lidawei
 *
 */
/**
 * @author lidawei
 *
 */
/**
 * @author lidawei
 *
 */
/**
 * @author lidawei
 *
 */
public class ModelUser 
{
 
	private String userID;
	private String userName;
	private String userPass;	
	private String sessionId;	
	private String lastActionTime;
    private List<ModelUserRole> rolesList;
    //save all permissions
    private String[] allpermissions;
    
	
	public String getUserName()
	{
		return userName;
	}
	public void setUserName(String value)
	{
		userName=value;
	}
	public String getUserPass()
	{ 
		return userPass;
	}
	public void setUserPass(String value)
	{
		userPass=value;
	}
	
	public String getUserID()
	{ 
		return userID;
	}
	public void setUserID(String value)
	{
		userID=value;
	}

	public String getSessionId()
	{
		return sessionId;
	}
	public void setSessionId(String value)
	{
		sessionId=value;
	}
	public String getLastActionTime()
	{
		return lastActionTime;
	}
	public void setLastActionTime(String value)
	{
		lastActionTime=value;
	}	
			
	public ModelUser()
	{
	}			
	public ModelUser(String name, String id ,String pass)
	{
		userName =name;
		userID = id;
		userPass = pass;
	}
	
	public String getId()
	{
		return userID;
	}
	
	/*�û�Ȩ��*/
	public void setRoles(List<ModelUserRole> roles)
	{
		rolesList = roles;
	}
	
	/*Roles name show in grid*/
	public String getRoles()
	{
		String result="";
		if (rolesList !=null && rolesList.size()>0)
		{
			for (ModelUserRole model : rolesList) {
				
				if (result.length()>0)
					result += ",";
				
				result += model.getRoleName();
			}
		}
		
		return result;
	}
	public String[] getAllpermissions() {
		return allpermissions;
	}
	public void setAllpermissions(String[] allpermissions) {
		this.allpermissions = allpermissions;
	}
	
	/*用户是否包含 permi*/
	public boolean concatPermission(String permi){
		boolean flag =false;
		
		if (allpermissions !=null && allpermissions.length>0){
			for (String perString : allpermissions) {
				if (permi.equals(perString))
				{
					flag=true;
					break;
				}
			}
		}		
		return flag;
	}
}
